<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width">
    <title>借款</title>
    <link href="../Content/css/style.css" rel="stylesheet">
    <script src="../Content/js/rem.js"></script>

</head>
<body>
<div id="loading">
    <img src="../Content/imgs/kbloading.gif">
</div>
    <div class="wrap">
        <div class="seabox">
            <input class="seainput" placeholder="请输入手机号码" id="input">
            <a href="javascript:;" class="seabtn"  onclick="seabtn()">搜索</a>
        </div>
        <div class="jktop">
            <img src="../Content/imgs/jktop.jpg">
        </div>

        <div class="box">
            <div class="bcon">
                <div class="list_lh">
                    <ul>
                        <li>
                            <p>张*兰注册成为新用户</p>
                        </li>
                        <li>
                            <p>李*注册成为新用户</p>
                        </li>
                        <li>
                        <p>刘*注册成为新用户</p>
                    </li>
                        <li>
                        <p>曹*英注册成为新用户</p>
                    </li>
                        <li>
                            <p>刘*美注册成为新用户</p>
                        </li>
                        <li>
                            <p>赵*侠注册成为新用户</p>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="btnbox">
            <div class="btn wydk">我要贷款</div>
            <div class="btn jyjl">交易记录</div>
        </div>
        <div class="cjrbox">
            <div class="xzbox">
                <p class="cjrnum">发现出借人(<span id="L"></span>)</p>
            </div>
            <ul class="jkrlist" id="jkrlist">
                <!--<li>-->
                    <!--<p class="cjje">5000-10000</p>-->
                    <!--<div class="cjrxx"><img src="../Content/imgs/gril.jpg"><span>张*君</span></div>-->
                    <!--<a class="jkbtn">找TA借</a>-->
                <!--</li>-->
            </ul>
        </div>
    </div>

    <ul class="footer" id="footer">
        <li class="jr active">借入</li>
        <li class="jc">借出</li>
        <li class="xx">消息</li>
        <li class="jl">交易</li>
        <li class="wd">我的</li>
    </ul>
<script src="../Content/js/jquery-2.2.4.min.js"></script>
<script src="../Content/js/scroll.js"></script>
<script src="../Content/js/layer-mobl.js"></script>
<script>
    //判断登录
    var dlzt=false;
    if(localStorage.phonenum==undefined||localStorage.phonenum=="undefined" || localStorage.phonenum==""){
        dlzt=false
    }else {
        dlzt=true;
    }
    var url="http://192.168.199.121:8080/daiqianlai";
    localStorage.url=url;
    //var url=" http://j.ccyjs.cn/DiscuzServer";
    //获取页面传递参数
//    let urs=window.location.search;
//    let strs=urs.substring(1);
//    let silp=strs.split('&');
//    let res={};
//    for (let i=0;i<silp.length;i++){
//        res[silp[i].split("=")[0]]=silp[i].split("=")[1];
//    } borrow/findLoanUserByPhonenum
    var param={
        page:1
    }
    $.ajax({
        type : "POST",
        url : url+"/borrow/getLoanUser",
        dataType : 'json',
        async: false,
        contentType : "application/json",
        data :JSON.stringify(param),
        success : function(ro) {
            console.log(ro);
            var strs="";
            $("#L").html(ro.count);
            $.each(ro.userList,function (index,el) {
                var name=ro.userList[index].name;
                strs+=`<li data-id=`+ro.userList[index].id+` data-userid=`+ro.userList[index].luser_id+` onclick="gotoztj(this)">
                    <p class="cjje">`+ro.userList[index].loanmoney+`</p>
                    <div class="cjrxx"><img src=`+ro.userList[index].tou+`><span>`+Name(name)+`</span></div>
                    <a class="jkbtn">找TA借</a>
                </li>`;
            });
            $(strs).appendTo("#jkrlist");
            $("#loading").hide();
        },
        error : function(err) {
            console.log(err);
        }
    });
    function seabtn() {
        var phone=$("#input").val();
        if(phone=="" || phone.length!=11){
            layer.open({
                content:"手机号输入有误",
                time:1
            });
            return
        }else {
            $.ajax({
                type : "GET",
                url : url+"/borrow/findLoanUserByPhonenum",
                dataType : 'json',
                async: false,
                contentType : "application/json",
                data :{
                    phonenum:$("#input").val()
                },
                success : function(ro) {
                    console.log(ro);
                    if(ro.length==0){
                        layer.open({
                            content:"此人暂无申请记录",
                            time:1
                        });
                    }else {
                        window.location.href="jkinfo.html?cjrid="+ro[0].id
                    }
                },
                error : function(err) {
                    console.log(err);
                }
            });
        }
    }
    $(function(){
        $("#footer li").on('click',function () {
            var index=$(this).index();
            $(this).addClass('active').siblings().removeClass("active");
            console.log(index);
            if(index===0){
                window.location.href="index.html"
            }else if(index===1){
                window.location.href="chujie.html"
            }else if(index===2){
                if(!dlzt){
                    window.location.href="login.html";
                }else {
                    window.location.href="messages.html"
                }
            }else if(index===3){
                if(!dlzt){
                    window.location.href="login.html";
                }else {
                    window.location.href="jiaoyi.html"
                }
            }else if(index===4){
                if(!dlzt){
                    window.location.href="login.html";
                }else {
                    window.location.href="my.html"
                }
            }
        });

        $("div.list_lh").myScroll({
            speed:40, //数值越大，速度越慢
            rowHeight:50 //li的高度
        });
        $(".wydk").on('click',function () {
            if(!dlzt){
                window.location.href="login.html";
            }else {
                window.location.href="wyjk.html"
            }
        });
        $(".jyjl").on('click',function () {
            if(!dlzt){
                window.location.href="login.html";
            }else {
                window.location.href="jiekuanjilu.html"
            }

        });
//        $(".cjrbox li").on('click',function () {
//            if(!dlzt){
//                window.location.href="login.html"
//            }else {
//                window.location.href="jkinfo.html"
//            }
//
//        })
    });

    function Name(name) {
        if(name.length==2){
            return name.substring(0,1)+"*"
        }else if(name.length==3){
            return name.substring(0,1)+"*"+name.substring(2,3)
        }else if(name.length==4){
            return name.substring(0,1)+"**"+name.substring(3,4)
        }else {
            return name
        }
    }
    function gotoztj(obj){
        var $this=$(obj);
        var id=$this.attr("data-id");
        var userid=$this.attr("data-userid");
        //console.log(id)
        if(!dlzt){
            window.location.href="login.html"
        }else {
            window.location.href="jkinfo.html?cjrid="+id+"&userid="+userid
        }
    }
</script>
</body>
</html>
